#! /usr/bin/env python3
#coding = utf-8

class Solution(object):
    def longestCommonPrefix(self, strs):
        test = set()
        res = ""
        pos = 0
        while True:
            for i in (strs):
                if pos < len(i):
                    test.add(i[pos])
                else:
                    test.clear()
                    break
            if len(test) == 1:
                res += test.pop()
            else:
                break
            pos += 1
            test.clear()
        return res


s = Solution()
print(s.longestCommonPrefix(["aa", "a"]))

